<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">

<head>
    <th:block th:include="include :: header('评论设置')" />
    <th:block th:include="include::bootstrap-select-css" />
</head>

<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content" th:with="commentConfig=${@configTag.getConfigValueMap('commentConfig')}">
        <div class="tabs-container">
            <ul class="nav nav-tabs" id="config-title">
                <li class="active"><a data-toggle="tab" href="#comment" aria-expanded="false">评论设置</a>
                </li>
            </ul>
            <div class="tab-content">
                <!-- 评论管理 -->
                <div id="comment" class="tab-pane active">
                    <div class="panel-body">
                        <form class="form-horizontal m" id="form-comment">
                            <div class="form-group">
                                <label class="col-sm-3 control-label is-">文章评论：</label>
                                <div class="col-sm-8">
                                    <label class="toggle-switch switch-solid">
                                        <input type="checkbox" id="oly.comment.open.article"
                                            th:checked="${commentConfig['oly.comment.open.article']}">
                                        <input type="hidden" name="oly.comment.open.article"
                                            th:value="${commentConfig['oly.comment.open.article']}" />
                                        <span></span>
                                    </label>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label is-">站点评论：</label>
                                <div class="col-sm-8">
                                    <label class="toggle-switch switch-solid">
                                        <input type="checkbox" id="oly.comment.open.site"
                                            th:checked="${commentConfig['oly.comment.open.site']}">
                                        <input type="hidden" name="oly.comment.open.site"
                                            th:value="${commentConfig['oly.comment.open.site']}" />
                                        <span></span>
                                    </label>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label is-">链接评论：</label>
                                <div class="col-sm-8">
                                    <label class="toggle-switch switch-solid">
                                        <input type="checkbox" id="oly.comment.open.links"
                                            th:checked="${commentConfig['oly.comment.open.links']}">
                                        <input type="hidden" name="oly.comment.open.links"
                                            th:value="${commentConfig['oly.comment.open.links']}" />
                                        <span></span>
                                    </label>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label is-">邮件回复：</label>
                                <div class="col-sm-8">
                                    <label class="toggle-switch switch-solid">
                                        <input type="checkbox" id="oly.comment.mailRestore"
                                            th:checked="${commentConfig['oly.comment.mailRestore']}">
                                        <input type="hidden" name="oly.comment.mailRestore"
                                            th:value="${commentConfig['oly.comment.mailRestore']}" />
                                        <span></span>
                                    </label>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label is-">评论默认状态：</label>
                                <div class="col-sm-8">
                                    <div class="radio-box" th:each="dict : ${@dictTag.getType('cms_comment_visible')}">
                                        <input type="radio" th:id="${dict.dictCode}" name="oly.comment.defauleVisible"
                                            th:value="${dict.dictValue}"
                                            th:checked="${commentConfig['oly.comment.defauleVisible'] eq dict.dictValue}">
                                        <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label is-">文字数量：</label>
                                <div class="col-sm-8">
                                  <input name=" oly.comment.max.size" th:value="${commentConfig[' oly.comment.max.size']}" class="form-control" type="number">
                                </div>
                              </div>
                        </form>
                    </div>
                </div>

            </div>
            <br>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include::bootstrap-select-js" />
    <script type="text/javascript">
        var prefix = ctx + "cms/comment";
        var myForm = "form-comment";
        $('#config-title a').click(function (e) {
            e.preventDefault();
            $(this).tab('show');
            myForm = $(this).attr('href').replace("#", "form-");
        });
        function setOpen() {
            $("input[name='oly.comment.mailRestore']").val($("input[id='oly.comment.mailRestore']").is(':checked'));
            $("input[name='oly.comment.open.article']").val($("input[id='oly.comment.open.article']").is(':checked'));
            $("input[name='oly.comment.open.site']").val($("input[id='oly.comment.open.site']").is(':checked'));
            $("input[name='oly.comment.open.links']").val($("input[id='oly.comment.open.links']").is(':checked'));
        }
        function submitHandler() {
            setOpen();
            var data = $("#"+myForm).serializeArray();
            data.push({"name": "configGroup", "value": "commentConfig"});
             if ($.validate.form()) {
               $.operate.save(prefix + "/updateByGk", data);
            }

        }
    </script>
</body>

</html>